extends Area2D

var speed = 800
var angle = 0

func _ready():
	pass

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	
	rotation_degrees = angle
	
	var direction = Vector2.UP.rotated(deg_to_rad(angle))
	
	position += speed * direction * delta
	
	# 销毁飞出屏幕外的子弹
	if (position.x < -10 or position.x > DisplayServer.window_get_size().x + 10
	or position.y<-10 or position.y> DisplayServer.window_get_size().y+10):
		queue_free()



func _on_body_entered(body):
	#if body.get_tree().get_nodes_in_group("explosion").size()==0:
		#body.add_child(ex)
	if body.state == global.STATE_ACTIVE:
		body.change_hp(-1)
	
	queue_free()
	
	
